<script lang="ts">
import { onLoad } from '@dcloudio/uni-app';
import { initVueI18n } from '@dcloudio/uni-i18n';
import { useAuthStore } from './store/auth';
import { useCountryStore } from '@/store/country';

export default {
  setup() {
    const countryStore = useCountryStore();
    countryStore.getCountryCode();

    const authStore = useAuthStore();
    authStore.CheckToken();
    authStore.SetprivacyText();

    const i18n = initVueI18n();

    onLoad(() => {
      const language = uni.getStorageSync('language');
      switch (language) {
        case 'en':
          uni.setLocale('en');
          i18n.setLocale('en');
          break;
        case 'ja':
          uni.setLocale('ja');
          i18n.setLocale('ja');
          break;
        case 'ko':
          uni.setLocale('ko');
          i18n.setLocale('ko');
          break;
        case 'zh_CN':
          uni.setLocale('zh-Hant');
          i18n.setLocale('zh-Hant');
          break;
        default:
          uni.setLocale('zh-Hans');
          i18n.setLocale('zh-Hans');
          break;
      }
    });
  }
};
</script>

<style lang="scss">
@use 'scss/main.scss';
</style>
